#include "widget.h"
#include "ui_widget.h"
#include <QFileDialog>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    //通过打开文件，对文件进行读取
    QString path = QFileDialog::getOpenFileName(this,"打开文件","D:/VS/cpp-code/1-6/1-6/test.cpp");
    ui->lineEdit->setText(path);
    QFile file(path);
    file.open(QIODevice::ReadOnly);
    QString text = file.readAll();
    file.close();
    //讲文件的内容打印到文档中
    ui->textEdit->setText(text);
}

Widget::~Widget()
{
    delete ui;
}

